package com.webSite.demo.cy.security;

import java.util.ArrayList;
import java.util.List;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

@Component
public class MyUserDetailService implements UserDetailsService {

//	@Autowired
//	private PasswordEncoder passwordEncoder;
	
	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		// return new User(username, "123456",AuthorityUtils.commaSeparatedStringToAuthorityList("admin"));
		System.out.println(username);
		List<GrantedAuthority> grantedAuthorities = new ArrayList <>();
		GrantedAuthority grantedAuthority = new SimpleGrantedAuthority("USER");
		grantedAuthorities.add(grantedAuthority);
		return new User(username, "660203",grantedAuthorities);
	}

}
